import logging
class Log:
    logger = None

    def __new__(cls, *args, **kwargs):
        if cls.logger == None:
            cls.logger = logging.getLogger('spam_application')
            cls.logger.setLevel(logging.DEBUG)
            # create file handler which logs even debug messages
            fh = logging.FileHandler('app.log', encoding='utf8')
            fh.setLevel(logging.DEBUG)

            # create formatter and add it to the handlers
            formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
            fh.setFormatter(formatter)
            # add the handlers to the logger
            cls.logger.addHandler(fh)
        return cls.logger


if __name__ == '__main__':
    log1 =Log()
    log2 =Log()
    print(log1 == log2)